/*
 * @Author: 杨上漂
 * @Date: 2025-03-01 15:41:58
 * @LastEditors: 杨上漂
 * @LastEditTime: 2025-03-01 16:03:01
 * @FilePath: \wjycj\assets\scripts\SnowBgView.js
 * @Description: 
 * 
 * Copyright (c) 2025 by ${git_name_email}, All Rights Reserved. 
 */
var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
    })(t, e);
}, function(t, e) {
    function n() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (n.prototype = e.prototype, 
    new n());
}), a = this && this.__decorate || function(t, e, o, n) {
    var c, r = arguments.length, i = r < 3 ? e : null === n ? n = Object.getOwnPropertyDescriptor(e, o) : n;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, o, n); else for (var a = t.length - 1; 0 <= a; a--) (c = t[a]) && (i = (r < 3 ? c(i) : 3 < r ? c(e, o, i) : c(e, o)) || i);
    return 3 < r && i && Object.defineProperty(e, o, i), i;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("ActivityManager"), s = e("LoadManager"), c = cc._decorator, l = c.ccclass, d = (c.property, 
function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.pool = new cc.NodePool(), t;
    }
    return i(t, e), t.prototype.start = function() {
        r.ActivityManager.getInstance().checkActivity(r.ActivityType.SNOW) ? (this.doEffect(), 
        this.schedule(this.doEffect, 16)) : this.node.destroy();
    }, t.prototype.doEffect = function() {
        for (var e = this, t = GA.rand(5, 10), o = 0; o < t; o++) this.getItem().then(function(t) {
            t.zIndex = -1, t.scale = Math.min(.2 + Math.random(), .6), t.y = 400, t.x = 100 * GA.rand(-5, 5), 
            t.parent = e.node, t.getComponent(sp.Skeleton).setAnimation(0, "animation", !0), t.getComponent(sp.Skeleton).premultipliedAlpha=false,
            e.doAction(t, GA.rand(0, 5), GA.rand(0, 16));
        });
    }, t.prototype.doAction = function(t, e, o) {
        var n = this;
        t.y = 400;
        var c = cc.tween(t);
        0 < e && c.delay(e), c.call(function() {
            t.getComponent(sp.Skeleton).setAnimation(0, "animation", !0);
        }), c.by(16 + o, {
            position: cc.v3(0, -800)
        }), c.call(function() {
            n.pool.put(t);
        }), c.start();
    }, t.prototype.getItem = function() {
        var n = this;
        return new Promise(function(e, t) {
            var o;
            0 < n.pool.size() ? e(n.pool.get()) : ((o = new cc.Node().addComponent(sp.Skeleton)).setAnimationCacheMode(sp.Skeleton.AnimationCacheMode.SHARED_CACHE), 
            o.enableBatch = !0, s.default.getInstance().loadRes({
                url: "skeleton/雪花/skeleton",
                type: sp.SkeletonData
            }).then(function(t) {
                o.skeletonData = t, e(o.node);
            }).catch(function() {
                t();
            }));
        });
    }, a([ l ], t);
}(cc.Component));

n.default = d;